utils: add basic test for export_dmabufs Now that we are relying on memfd, which should be available everywhere, we can test this helper. 
diff --git a/utils/src/dmabuf_exporter.rs b/utils/src/dmabuf_exporter.rs index ce19e9b..1d90c24 100644 --- a/utils/src/dmabuf_exporter.rs +++ b/utils/src/dmabuf_exporter.rs 
@@ -26,3 +26,43 @@    Ok(fds)  } + +#[cfg(test)] +mod tests { + use v4l2r::{memory::DmaBufSource, Format, PixelFormat, PlaneLayout}; + + use super::export_dmabufs; + + #[test] + fn test_export_dmabufs() { + const WIDTH: u32 = 640; + const HEIGHT: u32 = 480; + const BYTES_PER_LINE: u32 = WIDTH; + const SIZE_IMAGE_Y: u32 = BYTES_PER_LINE * HEIGHT; + const SIZE_IMAGE_UV: u32 = BYTES_PER_LINE * HEIGHT / 2; + + let format = Format { + width: WIDTH, + height: HEIGHT, + pixelformat: PixelFormat::from_fourcc(b"NV12"), + plane_fmt: vec![ + PlaneLayout { + sizeimage: SIZE_IMAGE_Y, + bytesperline: BYTES_PER_LINE, + }, + PlaneLayout { + sizeimage: SIZE_IMAGE_UV, + bytesperline: BYTES_PER_LINE, + }, + ], + }; + + let dmabufs = export_dmabufs(&format, 4).unwrap(); + assert_eq!(dmabufs.len(), 4); + for buf in dmabufs { + assert_eq!(buf.len(), 2); + assert!(buf[0].0.len() >= SIZE_IMAGE_Y as u64); + assert!(buf[1].0.len() >= SIZE_IMAGE_UV as u64); + } + } +}